from selenium import webdriver
import time
from playwright.sync_api import sync_playwright
import unittest
from selenium.webdriver.common.by import By
from ddt import ddt,file_data

@ddt
class test_A3mall(unittest.TestCase):
    def setUp(self) -> None:
        print('开始')
        self.driver = webdriver.Edge()
        self.driver.maximize_window()
        self.driver.get('http://10.59.9.12:7001/')

    def tearDown(self) -> None:
        time.sleep(5)
        self.driver.quit()
        print('结束')

    @file_data('login.json')
    def test_01_login(self,case_id,case_mk,case_qz,case_step,case_title,username,password,case_yq,case_sj,case_tgf,case_BugID,case_yxj,case_bz):
        # 登录
        self.driver.find_element(By.XPATH, '/html/body/div[1]/div/div[2]/ul/li[1]/a').click()
        time.sleep(1)
        print(case_id)
        print(case_title+"--------"+case_yxj)
        print(case_mk)
        print(case_qz)
        print(case_step)
        # 输入账号密码
        self.driver.find_element(By.NAME, 'username').send_keys(username)
        time.sleep(1)
        self.driver.find_element(By.NAME, 'password').send_keys(password)
        time.sleep(6)
        # 点击登录按钮
        self.driver.find_element(By.XPATH, '//*[@id="theForm"]/div[5]/a').click()
        print(case_yq)
        print(case_sj,case_tgf,case_BugID,case_bz)
        time.sleep(5)
        user = self.driver.find_element(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a').text
        print(user)
        if '18238680385' in user:
            assert '18238680385' in user


if __name__ == '__main__':
    unittest.main()